class TrapdoorRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	TrapdoorRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return 0; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		bool closed = (block.Data & 0x04) != 0;
		bool top = (block.Data & 0x08) != 0;
		byte dir = block.Data & ~(0x04 | 0x08);

		if (closed)
		{
			renderer->Translate(8, 8, 8);

			switch (dir)
			{
			case 0:
				renderer->Rotate(180, 0, 1, 0);
				break;
			case 2:
				renderer->Rotate(-90, 0, 1, 0);
				break;
			case 3:
				renderer->Rotate(90, 0, 1, 0);
				break;
			}
			renderer->Translate(-8, -8, -8);
			renderer->Draw(Box(Texture, Point3i(16, 16, 3), Point3i(0, 0, 0)).SetAll(Point2i(4 * 16, 5 * 16)));
		}
		else
		{
			if (!top)
			{
				renderer->Translate(8, 8, 8);
				renderer->Rotate(180, 1, 0, 0);
				renderer->Translate(-8, -8, -8);
			}

			renderer->Draw(Box(Texture, Point3i(16, 3, 16), Point3i(0, 0, 0)).SetAll(Point2i(4 * 16, 5 * 16)));
		}
	}
};